#light

namespace Langexplr.Abc

open System

type NamespaceKind =
   | Namespace = 0x08
   | PackageNamespace = 0x16
   | PackageInternalNs = 0x17
   | ProtectedNamespace = 0x18
   | ExplicitNamespace = 0x19
   | StaticProtectedNs = 0x1A
   | PrivateNs = 0x05


type Ns = Ns of string * NamespaceKind
with
    member this.Name 
      with get() = 
         match this with
         | Ns(name,_) -> name

    override this.ToString() =
       match this with
       | Ns(name,kind) -> sprintf "%s (%s)" name (kind.ToString())
end

type QualifiedName =
  | MQualifiedName of Ns array * string
  | CQualifiedName of Ns * string
  | SQualifiedName of string
with  
  override  this.ToString() =
     match this with 
     | MQualifiedName (namespaces,name)-> 
           String.Format("({1}).{0}",
                         name,
                         String.Join("|",Array.map (fun (x:Ns) -> x.ToString()) namespaces
                                     ))
     | CQualifiedName (Ns("",k),name) -> String.Format("({1}){0}",name,k.ToString())
     | CQualifiedName (Ns(ns,_),name) -> String.Format("{0}.{1}",ns,name)
     | SQualifiedName name -> name
end
